define(['appModule'], function(NFR)
{
    NFR.lazy.directive('ngReallyClick', ['$modal',
    function($modal) {
        var ModalInstanceCtrl = function($scope, $modalInstance) {
            $scope.ok = function() {
                $modalInstance.close();
            };

            $scope.cancel = function() {
              $modalInstance.dismiss('cancel');
            };
        };

        return {
            restrict: 'A',
            scope: {
                ngReallyClick: '&'
            },
            link: function(scope, element, attrs) {
                var message = attrs.ngReallyMessage;
                element.bind('click', function() {
                    var modalHtml = '<div class="modal-header confirmDialog">' + 
                    '<button type="button" class="close" data-dismiss="modal" ng-click="cancel()"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>' + 
                    '<h4 class="modal-title"><span class="glyphicon glyphicon-check"></span> Please confirm  </h4></div>';
                    modalHtml += '<div class="modal-body">' + message + '</div>';
                    modalHtml += '<div class="modal-footer"><button class="btn btn-primary" ng-click="ok()">Yes</button><button class="btn btn-warning" ng-click="cancel()">No</button></div>';

                    var modalInstance = $modal.open({
                        template: modalHtml,
                        controller: ModalInstanceCtrl,
                        backdrop:"static", 
                        keyboard:false
                    });

                    modalInstance.result.then(function() {
                        scope.ngReallyClick();
                    });
                    
                });

            }
        }
    }

  ])
});